<?php

declare (strict_types=1);
namespace Swb\Shop\Model;

use Hyperf\DbConnection\Model\Model as BaseModel;
/**
 * @property int $id 
 * @property string $building_id 
 * @property int $region_id 
 * @property int $business_district_id 
 * @property string $manager_id 
 * @property string $free_period 
 * @property string $deposit_demand 
 * @property string $first_pay_time 
 * @property string $pay_period 
 * @property int $project_status 
 * @property string $introduce 
 * @property int $up_down_status 
 * @property string $up_down_time 
 * @property int $hot_push_status 
 * @property string $hot_push_time 
 * @property string $create_by 
 * @property string $create_time 
 * @property string $update_by 
 * @property string $update_time 
 * @property int $del_flag 
 * @property string $ready_open_time 
 * @property int $in_shop 
 * @property int $formats 
 * @property string $number 
 * @property string $department 
 */
class TProject extends BaseModel
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 't_project';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [];
	protected $keyType = 'string';
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = ['id' => 'string', 'region_id' => 'integer', 'business_district_id' => 'integer', 'project_status' => 'integer', 'up_down_status' => 'integer', 'hot_push_status' => 'integer', 'del_flag' => 'integer', 'in_shop' => 'integer', 'formats' => 'integer'];
	public function building()
	{
		return $this->belongsTo(TBuilding::class,'building_id')
			->leftJoin('sys_business_areas as sb','sb.id','=','t_building.business_district_id')
			->select('t_building.id','business_district_id','building_name','sb.name','sb.province_name','sb.city_name','sb.area_name');

	}
	public function building_dict()
	{
		return $this->hasMany(TBuildingDictionary::class,'building_id','building_id');
	}
	/**
	 * User : 码农先生
	 * Email: 807098383@qq.com
	 * Website: http://blog.zsboss888.com
	 * (1商铺配套 2适合业态 3标签)
	 */
	public function house_dict()
	{
		return $this->hasMany(TProjectTag::class,'project_id')
			->selectRaw('t_project_tag.*,sys_data_dict.name')
			->leftJoin('sys_data_dict','sys_data_dict.id','=','t_project_tag.tag_id');
	}

	public function house()
	{
		return $this->hasOne(TShop::class,'project_id');
	}
}